<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="/favicon.ico" >
<LINK rel="Shortcut Icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/style.css" />
<!--/meta 作为公共模版分离出去-->
<title>编辑商品</title>
</head>
<body ng-controller="main">
<article class="page-container">
	<form action="<?php url('goods/goodsSave')?>" method="post" class="form form-horizontal" id="form-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商品名称：</label>
			<div class="formControls col-xs-8 col-sm-10">
				<input type="text" class="input-text" value="<?php echo $info['name']?>" placeholder="请输入商品名称" id="name" name="name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商品描述：</label>
			<div class="formControls col-xs-8 col-sm-10">
				<textarea name="descrip" id="descrip" class="textarea"  placeholder="请输入商品描述" onKeyUp="$.Huitextarealength(this,200)"><?php echo $info['descrip']?></textarea>
				<p class="textarea-numberbar"><em class="textarea-length">0</em>/200</p>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商品图片：</label>
			<div class="formControls col-xs-8 col-sm-10"> <span class="btn-upload form-group">
				<input class="input-text upload-url" type="text" name="image" id="uploadfile" >
				<a href="javascript:;" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont">&#xe642;</i> 浏览文件</a>
				<input id="file" type="file" multiple name="image[]" class="input-file"  value="">
				</span>
				<img id="img" src="<?php echo $pre.$info['image']?>" class="mt-15">
			</div>
		</div>

        <div class="row cl" id="business" <?php if($flag) echo 'hidden';?>>
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>所属商家：</label>
        <div class="formControls col-xs-8 col-sm-10">
            <select class="select" name="bid" id="bid" size="1">
                <option value="">请选择商家</option>
                <?php foreach($business as $v):?>
                <option value="<?php echo $v['id']?>" <?php if($v['id'] == $info['bid']) echo 'selected';?>><?php echo $v['name']?></option>
                <?php endforeach; ?>
            </select>
        </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商品类型：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <select class="select" name="type_id" id="type_id" size="1">
                    <option value="">请选择商品类型</option>
                    <?php foreach($type as $v):?>
                    <option value="<?php echo $v['id']?>" <?php if($v['id'] == $info['type_id']) echo 'selected';?>><?php echo $v['name']; if($v['business'] && !$flag) echo '('.$v['business'].')'; else echo '';?></option>
                    <?php endforeach; ?>
                </select>
            </div>
        </div>

        <div class="row cl" id="combo" hidden>
            <label class="form-label col-xs-3 col-sm-2"></label>
            <div class="formControls col-xs-8 col-sm-10">
                <span class="c-red">*</span>套餐商品：
                <?php foreach($goods_list as $v){?>
                <input type="checkbox" value="<?php echo $v['id']?>" <?php if(in_array($v['id'],$goods_combo)) echo 'checked';?> name="gid[]" id="gid" class="ml-5"/><?php echo $v['name'];}?>
            </div>
        </div>

		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<input type="hidden" name="id" value="<?php echo $info['id']?>" />
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/admin/js/layer.js"></script>
<script type="text/javascript" src="/static/admin/js/H-ui.min.js"></script>
<script type="text/javascript" src="/static/admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.validate.js"></script>
<script type="text/javascript" src="/static/admin/js/validate-methods.js"></script>
<script type="text/javascript" src="/static/admin/js/messages_zh.js"></script>
<script type="text/javascript" src="/static/admin/lib/My97DatePicker/WdatePicker.js"></script>
<!--/_footer /作为公共模版分离出去--> 

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
$(function(){
    var type_id = $('#type_id').val();
    if(type_id == 1){
        $('#combo').show();
    }
    $('#type_id').change(function(){
        var type_id = $('#type_id').val();
        if(type_id == 1){
            $('#combo').show();
        } else {
            $('#combo').hide();
            $("input[type='checkbox']:checked").prop("checked", false);
        }
    });
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	$("#form-add").validate({
		rules:{
			name: {required: true},
			descrip: {required: true},
			bid: {required: true},
			type_id: {required: true},
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			var options = {
				success: function (data) {
					if(data.code==0){
						layer.msg(data.msg,{icon:1,time:1000});
						setInterval("closeWindow()",1000);
					}else{
						layer.msg(data.msg,{icon:5,time:1000});
					}
				}
			};
            var type_id = $('#type_id').val();
            var up_id = $('#up_id').val();
			if(type_id != 1 && up_id == 0){
                layer.msg('请选择上级',{icon:5,time:1000});
            } else{
                $(form).ajaxSubmit(options);
            }
		}
	});
});
function closeWindow() {
	var index = parent.layer.getFrameIndex(window.name);
	window.parent.location.reload();
}
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>